home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / listobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  1.9 KB  |  51 lines

  1. #ifndef Py_LISTOBJECT_H
  2. #define Py_LISTOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* List object interface */
  8.  
  9. /*
  10. Another generally useful object type is an list of object pointers.
  11. This is a mutable type: the list items can be changed, and items can be
  12. added or removed.  Out-of-range indices or non-list objects are ignored.
  13.  
  14. *** WARNING *** PyList_SetItem does not increment the new item's reference
  15. count, but does decrement the reference count of the item it replaces,
  16. if not nil.  It does *decrement* the reference count if it is *not*
  17. inserted in the list.  Similarly, PyList_GetItem does not increment the
  18. returned item's reference count.
  19. */
  20.  
  21. typedef struct {
  22.     PyObject_VAR_HEAD
  23.     PyObject **ob_item;
  24. } PyListObject;
  25.  
  26. extern DL_IMPORT(PyTypeObject) PyList_Type;
  27.  
  28. #define PyList_Check(op) ((op)->ob_type == &PyList_Type)
  29.  
  30. extern DL_IMPORT(PyObject *) PyList_New Py_PROTO((int size));
  31. extern DL_IMPORT(int) PyList_Size Py_PROTO((PyObject *));
  32. extern DL_IMPORT(PyObject *) PyList_GetItem Py_PROTO((PyObject *, int));
  33. extern DL_IMPORT(int) PyList_SetItem Py_PROTO((PyObject *, int, PyObject *));
  34. extern DL_IMPORT(int) PyList_Insert Py_PROTO((PyObject *, int, PyObject *));
  35. extern DL_IMPORT(int) PyList_Append Py_PROTO((PyObject *, PyObject *));
  36. extern DL_IMPORT(PyObject *) PyList_GetSlice Py_PROTO((PyObject *, int, int));
  37. extern DL_IMPORT(int) PyList_SetSlice Py_PROTO((PyObject *, int, int, PyObject *));
  38. extern DL_IMPORT(int) PyList_Sort Py_PROTO((PyObject *));
  39. extern DL_IMPORT(int) PyList_Reverse Py_PROTO((PyObject *));
  40. extern DL_IMPORT(PyObject *) PyList_AsTuple Py_PROTO((PyObject *));
  41.  
  42. /* Macro, trading safety for speed */
  43. #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
  44. #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
  45. #define PyList_GET_SIZE(op)    (((PyListObject *)(op))->ob_size)
  46.  
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* !Py_LISTOBJECT_H */
  51.